package common

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/common"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// PreAuthCompleteService 预授权完成服务
type PreAuthCompleteService struct {
	*services.BaseService
}

// NewPreAuthCompleteService 创建预授权完成服务
func NewPreAuthCompleteService(config *core.Config) *PreAuthCompleteService {
	return &PreAuthCompleteService{
		BaseService: services.NewBaseService(config),
	}
}

// PreAuthComplete 预授权完成
func (s *PreAuthCompleteService) PreAuthComplete(request *common.PreAuthCompleteRequest) (*common.PreAuthCompleteResponse, error) {
	response := common.NewPreAuthCompleteResponse()
	err := s.Post(request, response, "/open/trans/preauthcomplete")
	if err != nil {
		return nil, err
	}
	return response, nil
}
